import time

from selenium.webdriver.common.by import By
from Page import Page
from time import sleep

class Page1(Page):
    shouye_py = (By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a')
    def shouye(self):
        self.click(self.shouye_py)
    #点击商品
    shangpin_py = (By.XPATH,'/html/body/div[8]/div[1]/div[2]/div[2]/ul/li[3]/div[2]/a')
    def shangpin(self):
        self.click(self.shangpin_py)
    #点击加入购物车
    jiarugwc_py = (By.XPATH,'//*[@id="add-cart"]')
    def jiarugwc(self):
        self.click(self.jiarugwc_py)
    #点击购物车
    dianjigwc_py = (By.XPATH,'/html/body/div[3]/div[3]/div[2]/a')
    def dianjigwc(self):
        self.click(self.dianjigwc_py)
    #断言3 我的购物车
    dy3_py = (By.XPATH,'/html/body/div[4]/div[1]/a[2]')
    def dy3(self):
        self.text(self.dy3_py)
    #点击删除
    delete_py = (By.XPATH,'//*[@id="cart-box"]/div[1]/table/tbody/tr[2]/td[7]/a')
    def delete(self):
        self.click(self.delete_py)
    #点击确定
    queren_py = (By.XPATH,'//*[@id="layui-layer1"]/div[3]/a[1]')
    def queren(self):
        self.click(self.queren_py)

    def test_A3Mall_02(self):
        self.shouye()
        self.shangpin()
        self.jiarugwc()
        time.sleep(4)
        self.dianjigwc()
        time.sleep(4)
        print(self.dy3())
        time.sleep(3)
        self.delete()
        time.sleep(3)
        self.queren()